/*#################################################

Image Rollover | v1.2 
Max Felker | max@bigroomstudios.com

Creates an image rollover in a specified container with event observation

#################################################*/

var Rollover = Class.create({

	initialize: function(config) {
	
		this.container = $(config.container);
		this.img_off = Builder.node('img', { id: config.container+"-off", src: config.img_off, border:0, style: "display:none" });
		this.img_on = Builder.node('img', { id: config.container+"-on", src: config.img_on, border:0, style: "display:none" });

		this.container.appendChild(this.img_off);
		this.container.appendChild(this.img_on);
	
		this.img_off = $(config.container+"-off");			
		this.img_on = $(config.container+"-on");			
		
		this.img_off.show();
		
		this.container.on('mouseenter',this.img_hover.bind(this));
		this.container.on('mouseleave',this.img_idle.bind(this));
		
		live.rollovers.set(this.container.id,this);				

	},
	
	img_hover: function() {
		this.img_off.hide();
		this.img_on.show();
	},
	
	img_idle: function() {
		this.img_on.hide();
		this.img_off.show();
	},

	stop_rollover: function() {
		
		Event.stopObserving(this.container);

	}

});
